package com.qidian.mes.qc.controller;

import com.qidian.mes.pojo.QcIndex;
import com.qidian.mes.qc.service.IndexService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 朱静炜
 * @Company 起点编程
 * @Time 2023/10/27 9:58
 * @Description
 */
@RestController
@CrossOrigin
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private IndexService indexService;
    @DeleteMapping("/delete")
    public MESResult deleteById(Long indexId){
        return indexService.deleteById(indexId);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody QcIndex qcIndex){
        return indexService.update(qcIndex);
    }

    @GetMapping("/selectById")
    public MESResult selectById(Long indexId){
        return indexService.getById(indexId);
    }
    /**
     * 自动生成项目编号
     * @return
     */
    @RequestMapping("/genId")
    public MESResult genId(){
        return indexService.genId();
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody QcIndex qcIndex){
        return indexService.save(qcIndex);
    }
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, QcIndex qcIndex){
        return indexService.list(qcIndex,page,limit);
    }
}
